package club.xyes.remotedisplay.controller;

import club.xyes.remotedisplay.jni.AbstractOLEDScreen;
import club.xyes.remotedisplay.jni.OLEDScreen;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {
    private OLEDScreen screen;

    @GetMapping("/init")
    public String init() {
        screen = AbstractOLEDScreen.getInstance(AbstractOLEDScreen.OLED_12864);
        screen.init();
        return "OK";
    }

    @GetMapping("/display")
    public String display() {
        screen.display();
        return "OK";
    }

    @GetMapping("/str")
    public String str(String str, String font, int size, int x, int y) {
        screen.drawString(str, font, size, x, y);
        return "OK";
    }

    @GetMapping("/superposition")
    public String superposition0(int x, int y, int d, int l) {
        int[] data = new int[l];
        for (int i = 0; i < data.length; i++) {
            data[i] = d;
        }
        screen.superposition(x, y, data);
        screen.show();
        return "OK";
    }
}
